package com.speak.sparkadminserver.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.speak.sparkadminserver.dao.NutRoleDao;
import com.speak.sparkadminserver.domain.NutRole;
import com.speak.sparkadminserver.service.NutRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @version 1.0
 * @Author Xing
 * @Date 2023/2/18 17:40
 */
@Service
public class NutRoleServiceImpl extends ServiceImpl<NutRoleDao, NutRole> implements NutRoleService {
    @Autowired
    private NutRoleDao dao;
    @Override
    public boolean Save(NutRole user) {
        try{
            NutRole nutRole = new NutRole();
            nutRole.setId(0L);
            nutRole.setUserId(1L);
            nutRole.setRole("admin");
            nutRole.setRoleName("管理员");
            nutRole.setRoleName("管理员");
            nutRole.setCreateTime(new Date());
            nutRole.setUpdateTime(new Date());
            System.out.println(nutRole);
            super.save(user);
        }catch (Exception e){
            return false;
        }
        return true;
    }

    @Override
    public boolean SaveUserRole(Long id) {
        NutRole role = new NutRole();
        role.setRole("user");
        role.setUserId(id);
        role.setRoleName("普通用户");
        role.setCreateTime(new Date());
        role.setRemarkes("普通用户");
        role.setUpdateTime(new Date());
        super.save(role);
        return false;
    }

    @Override
    public Long GetroleId(Long userId) {
        return dao.GetroleId(userId);
    }

}
